/**
 * @file App.tsx
 * @description 入口文件
 */
import React from 'react';
import {Provider,} from 'react-redux';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import { setJSExceptionHandler } from 'react-native-exception-handler';
import {StatusBar,Alert} from 'react-native';
import {NativeBaseProvider} from 'native-base';
import Hotupdate from 'react-native-update';
import store from './redux/store';
import Router from './router';

const App: React.FC = () => {
  // const globalJSErrorHandler = (error: any, isFatal: any) => {
  //   if (error && error.name && error.message) {
  //     const errorObject = {
  //       errorName: "代码错误",
  //       errorMsg: error.message
  //     };
  //     // request.sendJSException(JSON.stringify(errorObject));
  //     // 阻止程序在异常通知完成前崩溃
  //     Alert.alert(
  //       "错误提示",
  //       "抱歉！由于应用出现未知错误即将重启，请您谅解。",
  //       [
  //         {
  //           text: "确认",
  //           onPress: () => {
  //             Hotupdate.reloadJSBundle();
  //           }
  //         }
  //       ],
  //       { cancelable: false }
  //     );
  //   }
  // };
  // setJSExceptionHandler(globalJSErrorHandler, true);

  return (
    // Redux 包裹容器
    <Provider store={store}>
        {/* NativeBae 容器 */}
        {/* 警告 In React 18, SSRProvider is not necessary and is a noop. You can remove it from your app
        @reference  https://github.com/GeekyAnts/NativeBase/issues/5758
        */}
      <NativeBaseProvider>
        {/* SafeArea组件 包裹容器 */}
        <SafeAreaProvider>
          {/* 状态栏颜色 */}
          {/* <View style={{width:'100%',height: 44, backgroundColor:'#4F94F9'}}></View> */}
          <StatusBar translucent={true} barStyle="light-content" backgroundColor="#4F94F9" />
          {/* 路由及组件注册 */}
          <Router />
        </SafeAreaProvider>
      </NativeBaseProvider>
    </Provider>
  );
};

export default App;
